<ot-view>

    <div class="row">
        <div class="col-md-12 ot-view-title">
            {{branch.name}}
            <ot-entity-decorations entity="branch"></ot-entity-decorations>
            <div ng-if="templateDefinition" class="ot-branch-template">
                <span class="fa fa-share fa-flip-vertical">
                </span>
                <a href="#/branch/{{templateDefinition.id}}">
                    {{templateDefinition.name}}
                </a>
            </div>
            <div ng-if="branch.description" class="ot-description">
                {{branch.description}}
            </div>
        </div>
    </div>

    <ot-entity-disabled entity="branch" callback="reloadBranch()">
        The branch is disabled.
    </ot-entity-disabled>

    <div class="row" ng-if="branch.type != 'TEMPLATE_DEFINITION'" ng-show="builds.length > 0">
        <div class="col-md-12">
            <ng-include src="'app/view/fragment.branchBuildView.tpl.html'"></ng-include>
        </div>
    </div>

    <div class="row" ng-show="branch.type != 'TEMPLATE_DEFINITION' && builds && builds.length == 0">
        <div class="col-md-12">
            <div class="alert alert-warning">
                No build has been created for this branch or the filter is too restrictive.
                <button ng-show="currentBuildFilterResource" class="btn btn-sm btn-default pull-right" ng-click="buildFilterErase()">
                    Reset filter
                </button>
            </div>
        </div>
    </div>

    <div class="row" ng-show="(!branch || branch.type != 'TEMPLATE_DEFINITION') && loadingBuildView">
        <div class="col-md-12">
            <div class="alert alert-warning">
                <span class="fa fa-spinner fa-spin"></span>
                Loading the builds...
            </div>
        </div>
    </div>

    <div class="row" ng-if="branch.type == 'TEMPLATE_DEFINITION'">
        <div class="col-md-12 alert alert-info">
            This branch is a template and no build can be associated to it.
        </div>
    </div>

    <div class="row">
        <div class="col-md-4">
            <ot-section-title>Promotion levels</ot-section-title>
            <ot-noentry list="promotionLevels">
                No promotion level has been created yet.
            </ot-noentry>
            <div ng-if="promotionLevels" class="ot-entity-sortable-list"
                    ui-sortable="promotionLevelSortOptions" ng-model="promotionLevels">
                <div ng-repeat="promotionLevel in promotionLevels" class="ot-entity-sortable-list-item ot-decoration-list">
                    <span class="ot-entity-sortable-list-handle"
                          ng-if="branchView.links._reorderPromotionLevels"
                          title="Move this to reorder the promotion levels">&nbsp;</span>
                    <span class="ot-entity-sortable-list-image">
                        <ot-entity-image entity="promotionLevel" link="#/promotionLevel/{{promotionLevel.id}}"></ot-entity-image>
                    </span>
                    <a href="#/promotionLevel/{{promotionLevel.id}}" class="ot-entity-sortable-list-link">
                        {{promotionLevel.name}}
                    </a>
                    <ot-entity-embedded-decorations decorations="promotionLevel.decorations"></ot-entity-embedded-decorations>
                </div>
            </div>
            <button ng-if="branch._createPromotionLevel" type="button" class="btn btn-default"
                    ng-click="createPromotionLevel()">New promotion level
            </button>
        </div>
        <div class="col-md-4">
            <ot-section-title>Validation stamps</ot-section-title>
            <ot-noentry list="validationStamps">
                No validation stamp has been created yet.
            </ot-noentry>
            <div ng-if="validationStamps" class="ot-entity-sortable-list"
                 ui-sortable="validationStampSortOptions" ng-model="validationStamps">
                <div ng-repeat="validationStamp in validationStamps" class="ot-entity-sortable-list-item">
                    <span class="ot-entity-sortable-list-handle"
                          ng-if="branch._reorderValidationStamps"
                          title="Move this to reorder the validation stamps">&nbsp;</span>
                    <span class="ot-entity-sortable-list-image">
                        <ot-entity-image entity="validationStamp" link="#/validationStamp/{{validationStamp.id}}"></ot-entity-image>
                    </span>
                    <a href="#/validationStamp/{{validationStamp.id}}" class="ot-entity-sortable-list-link">
                        {{validationStamp.name}}
                    </a>
                    <span ng-if="validationStamp.dataType">
                        <ot-validation-data-type-decoration value="validationStamp.dataType"></ot-validation-data-type-decoration>
                    </span>
                </div>
            </div>
            <button ng-if="branch._createValidationStamp" type="button" class="btn btn-default"
                    ng-click="createValidationStamp()">New validation stamp
            </button>
        </div>
        <div class="col-md-4">
            <ot-section-title>Properties</ot-section-title>
            <div class="row">
                <div class="col-md-12">
                    <ot-entity-properties entity="branch"></ot-entity-properties>
                </div>
            </div>
            <ot-entity-events entity="branch"></ot-entity-events>
        </div>
    </div>
</ot-view>